<template>
  <div>
    <div class="modal">
      <div class="modal-bg" @click="PartCloses"></div>
      <div class="pub-w">
        <div class="rele-titles" v-show="XGShow"><img @click="PartCloses"src="../assets/img/tub.png" alt="">添加分区</div>
        <div class="rele-titles" v-show="TJShow"><img @click="PartCloses" src="../assets/img/tub.png" alt="">添加分区</div>
        <div class="pub-list">
          <div class="pub-li">
            <div class="pub-title">分区名称</div>
            <div class="pub-input"><input type="" name="" value=""
                                          v-model="title"></div>
          </div>
          <div class="pub-li">
            <div class="pub-title">排序值</div>
            <div class="pub-input"><input type="number" name="" v-model="sort">
            </div>
          </div>
          <div class="pub-li">
            <el-button v-show="XGShow" @click="xiugaifq" type="primary">修改</el-button>
            <el-button v-show="TJShow" @click="tianjiafq" type="primary" style="margin-left: -50px; position: absolute">添加</el-button>
            <div></div>
            <el-button @click="PartCloses" type="primary" >取消</el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script type="text/babel">
  export default {
    props: {
      LDmodal: {
        type: Function
      },
      PartClose: {
        type: Function
      },
      FQid: {
        type: Number
      },
      // fqtitle:{
      //   type:String
      // }
    },
    data() {
      return {
        title: '',
        // titleSec: '',
        sort: '',
        sortSec: '',
        TJShow: true,
        XGShow: false,
      }
    },
    methods: {
      PartCloses(){
        this.title = '';
        this.sort = '';
        this.PartClose();
      },
      TJgo() {
        let that = this;
        that.TJShow = true;
        that.XGShow = false;
      },
      XGgo() {
        let that = this;
        that.TJShow = false;
        that.XGShow = true;
      },
      tianjiafq() {
        this.$http.post('/newapi/Premisespartition/add', {
          premises_id: this.$route.params.id,
          title: this.title,
          sort: this.sort
        }).then(res => {
          if (res.data.status === 200) {
            this.PartClose();
            this.$store.state.messageString = res.data.message;
            this.LDmodal();
            this.title = '';
            this.sort = '';
          } else {
            this.$store.state.messageString = res.data.message;
            this.LDmodal();
          }
        }).catch(err => {
          console.log(err)
        })
      },
      xiugaifq(id) {
        this.$http.post('/newapi/Premisespartition/add', {
          id: this.$store.state.FQid,
          premises_id: this.$route.params.id,
          title: this.title,
          sort: this.sort
        }).then(res => {
          if (res.data.status === 200) {
            this.$store.state.messageString = res.data.message;
            this.PartClose();
            this.LDmodal();
            this.title = '';
            this.sort = '';
          } else {
            this.$store.state.messageString = res.data.message;
            this.LDmodal();
          }
        }).catch(err => {
          console.log(err)
        })
      },
      gettitle() {
        let that = this;
        that.$http.get('/newapi/Premisespartition/details', {
          params: {
            id: that.$store.state.FQid
          }
        }).then(res => {
          that.title = res.data.res.title;
          that.sort = res.data.res.sort;
        }).catch(err => {
          console.log(err)
        });
      }
    },
    computed: {},
    watch: {},
    mounted() {
    },
    created() {

    }
  }
</script>
<style scoped>
  /*.pub-li button {*/
    /*width: 100px;*/
    /*font-size: 1.1em;*/
    /*background: #ed7d31;*/
    /*color: #ffffff;*/
    /*border: none;*/
    /*float: left;*/
    /*border-radius: 5px;*/
    /*line-height: 35px;*/
  /*}*/
  .pub-li button:last-child {
    float: right;
    background: none;
    border: 1px solid #ed7d31;
    color: #ed7d31
  }
  .pub-list {
    width: 100%;
    float: left;
    margin-top: 80px;
    text-align: center;
  }
  .pub-input {
    width: 70%;
    float: left;
  }
  .pub-input input {
    width: 100%;
    /*line-height: 27px;*/
    height: 27px;
    float: left;
    border-radius: 5px;
    border: 1px solid #d3d3d3;
  }
  .pub-li {
    margin-top: 5px;
    width: 80%;
    height: 50px;
    display: inline-block;
  }
  .pub-title {
    width: 30%;
    line-height: 27px;
    text-align: center;
    font-size: 1.1em;
    float: left;
  }
  .pub-w {
    width: 20%;
    left: 40%;
    /*height: 210px;*/
    top: 50%;
    overflow: hidden;
    padding-bottom: 20px;
    margin-top: -105px;
    background: #ffffff;
    border-radius: 5px;
    position: absolute;
    z-index: 10;
  }
  img:hover {
    background: #bd2c00 !important;
    color: #ffffff;
  }
  img{
    /*position: fixed;*/
    flex-star:40px;
    /*margin-left: 44%;*/
    position: relative;

  }
  img{
    left: 170%;
  }
  .rele-titles {
    width: 10%;
    padding: 0 0.5%;
    line-height: 50px;
    font-size: 2em;
    color: #000;
    background: #f5f5f7;
    position: fixed;
    z-index: 9;
    border-bottom: 1px solid #d3d3d3;
    padding-right: 200px;
  }
</style>
